package com.ctrl.riveradministrator.mvp.presenter;

import android.util.Log;

import com.ctrl.riveradministrator.base.BaseObserver;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.mvp.model.Login;
import com.ctrl.riveradministrator.mvp.view.activity.login.LoginView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class LoginPresenter extends BasePresenter<LoginView> {

    public LoginPresenter(LoginView baseView) {
        super(baseView);
    }


    public void login(String username, String password) {
        Map<String, String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        attachView(apiService.login(map), new BaseObserver<Login>(getBaseView()) {

            @Override
            public void onSuccess(Login model) {
                //Log.d("LoginPresenter", "onSuccess: ");
                getBaseView().onSuccess(model);
            }

            @Override
            public void onSuccess(List<Login> model) {

            }

            @Override
            public void onFailed(String msg) {
                getBaseView().onFailed(msg);
            }

        });
    }
}
